<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      body {
        background: #000;
      }
      header {
        color: rgba(67, 175, 217, 1);
        font-size: 32px;
      }
    </style>
  </head>
  <body>
    <header id="title">SDA示云智图</header>
    <header id="age">123</header>
  </body>
  <script>
    // 平台数据对接方式示例（需在script标签中编写）:
    /**
     * 1.定义监听的iframe元素的唯一标识格式: 元素id_iframe_load
     * （用于将当前文档流加载后通知平台发送数据）
     * */
    const listenLoadName = "NMjTjf_iframe_load";
    // 2. 整体文档流加载后，通知平台进行数据推送
    window.onload = () => {
      window.parent.EventPublisher.publish(listenLoadName);
    };
    // 3.接收到信息的业务逻辑
    window.onmessage = function (e) {
      console.info("接收到來自SDA的平台信息: ", e);
      callback(e.data);
    };
    // 4.业务逻辑实现
    function callback(data) {
      console.log("回调数据", data);
      var titleEle = document.getElementById("title");
      var ageEle = document.getElementById("age");
      titleEle.innerText = data[0].testname;
      ageEle.innerText = data[0].testage;
    }

    // const listenSendName = "NMjTjf_iframe_send"
    // window.parent.EventPublisher.subscribe(listenSendName,(data) => {
    //   console.info("接收到來自SDA的平台信息: ", data);
    //   callback(data)
    // })
  </script>
</html>
